package com.jcompressor.model.config;

/*
 * Copyright (c) 2011, Scott Carnett
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
 * following conditions are met:
 * 
 *     * Redistributions of source code must retain the above copyright notice, this list of conditions and the
 *       following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
 *       following disclaimerin the documentation and/or other materials provided with the distribution.
 *     * Neither the name of jcompressor nor the names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

import java.io.Serializable;

import org.apache.commons.lang.builder.ToStringBuilder;

import com.jcompressor.JcompressorContext;

/**
 * @author Scott Carnett
 */
public class YUI implements Serializable {
	
	private static final long serialVersionUID = -7948830585225568946L;
	
	private String charset;
	private int lineBreak;
	private Boolean munge;
	private Boolean verbose;
	private Boolean preserveAllSemiColons;
	private Boolean disableOptimizations;
	
	public YUI() {
		this.charset = "UTF-8";
		this.lineBreak = -1;
		this.munge = Boolean.TRUE;
		this.verbose = Boolean.FALSE;
		this.preserveAllSemiColons = Boolean.FALSE;
		this.disableOptimizations = Boolean.FALSE;
	}
	
	/**
	 * Gets the charset
	 * @return String with the charset
	 */
	public String getCharset() {
		return JcompressorContext.getConfigurator().getPropertyExpander().expandProperties(this.charset);
	}
	
	/**
	 * Gets the line break
	 * @return int with the line break
	 */
	public int getLineBreak() {
		return this.lineBreak;
	}
	
	/**
	 * Gets the munge status
	 * @return Boolean with the value of true if munge is enabled; otherwise false
	 */
	public Boolean isMunge() {
		return this.munge;
	}
	
	/**
	 * Gets the verbose status
	 * @return Boolean with the value of true if verbose is enabled; otherwise false
	 */
	public Boolean isVerbose() {
		return this.verbose;
	}
	
	/**
	 * Gets the preserve all semi-colons status
	 * @return Boolean with the value of true if preserve all semi-colons is enabled; otherwise false
	 */
	public Boolean isPreserveAllSemiColons() {
		return this.preserveAllSemiColons;
	}
	
	/**
	 * Gets the disable optimizations status
	 * @return Boolean with the value of true if disable optimizations is enabled; otherwise false
	 */
	public Boolean isDisableOptimizations() {
		return this.disableOptimizations;
	}
	
	/**
	 * Sets the charset
	 * @param charset the charset
	 */
	public void setCharset(final String charset) {
		this.charset = charset;
	}
	
	/**
	 * Sets the line break
	 * @param lineBreak the lime break
	 */
	public void setLineBreak(final int lineBreak) {
		this.lineBreak = lineBreak;
	}
	
	/**
	 * Sets the munge status
	 * @param munge the munge status
	 */
	public void setMunge(final Boolean munge) {
		this.munge = munge;
	}
	
	/**
	 * Sets the verbose status
	 * @param verbose the verbose status
	 */
	public void setVerbose(final Boolean verbose) {
		this.verbose = verbose;
	}
	
	/**
	 * Sets the preserve all semi-colons status
	 * @param preserveAllSemiColons the preserve all semi-colons status
	 */
	public void setPreserveAllSemiColons(final Boolean preserveAllSemiColons) {
		this.preserveAllSemiColons = preserveAllSemiColons;
	}
	
	/**
	 * Sets the disable optimizations status
	 * @param disableOptimizations the disable optimizations status
	 */
	public void setDisableOptimizations(final Boolean disableOptimizations) {
		this.disableOptimizations = disableOptimizations;
	}
	
	/**
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return new ToStringBuilder(this)
			.append("Charset", this.getCharset())
			.append("Line Break", this.getLineBreak())
			.append("Munge", this.isMunge())
			.append("Verbose", this.isVerbose())
			.append("Preserve All Semi-Colons", this.isPreserveAllSemiColons())
			.append("Disable Optimizations", this.isDisableOptimizations())
			.toString();
	}
	
}